package com.demo.controller_admin;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.demo.dao_admin.EmployeeDAO;
import com.demo.entity.Employee;

@Controller("adminEmployeeController")
@RequestMapping(value = "/${site.adminUrlPrefix}/employee")
public class EmployeeController {
	
	@Resource(name = "adminEmployeeDAO")
	EmployeeDAO employeeDAO;

	/**
	 * 根据课程编号查单个课程
	 * @param id
	 * @return
	 */
//	@GetMapping(value = "/{id}")
//	public @ResponseBody Employee findById(@PathVariable("id") Long id) {
//		return employeeDAO.findById1(id);
//	}
	
	/**
	 * 动态查询课程
	 * @param p
	 * @param employee
	 * @return
	 */
	@GetMapping(value = "/search")
	public @ResponseBody List<Employee> findAll(Integer p) {
		if(p==null)	p=1;
		Sort sort = new Sort(Sort.Direction.ASC, "id");
		Pageable pageable = PageRequest.of(p, 10, sort);
		return employeeDAO.findAll1(1);
	}

}